﻿using NCache;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;

namespace CacheTestApp.Helper
{
    public static class CollectionExtensions
    {
        public static bool ToObservable<T>(this List<T> list, ObservableCollection<T> observable, string tokenTag = "normal")
        {
            try
            {
                foreach (T t in list)
                {
                    if (t is ImageCacheModel)
                    {
                        (t as ImageCacheModel).TokenTag = tokenTag;
                    }
                    observable.Add(t);
                }
                return true;
            }
            catch
            {
                Debug.WriteLine("ToObservable eror : " + typeof(T));
            }
            return false;
        }
    }
}
